package com.example.userservice.rabbitmq.consumer;

import lombok.extern.slf4j.Slf4j;
import org.example.entity.constants.Constants;
import org.example.entity.dto.MessageSendDto;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author susu
 * @Date 2024/10/7
 */
@Component
@Slf4j
public class UserConsumer {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = Constants.USER_QUEUE),
            exchange = @Exchange(name = Constants.EXCHANGE_CHAT_TOPIC_NAME,type = ExchangeTypes.TOPIC),
            key = {Constants.USER_QUEUE_ROUTING_KEY}
    ))
    public void listenGroupQueue(MessageSendDto messageSendDto){
        System.out.println(messageSendDto);
        log.info("消息已接收：{}",messageSendDto.getMessageId());
    }
}
